package.cpath = package.cpath .. ';C:/Users/win/AppData/Roaming/JetBrains/IdeaIC2020.3/plugins/intellij-emmylua/classes/debugger/emmy/windows/x86/?.dll'
local dbg = require('emmy_core')
dbg.tcpConnect('localhost', 9966)

package.path = package.path .. ";C:/Users/win/Documents/_lua/util/?.lua"

local Map = require("Map")


function Test1()
    local map = Map.new()
    print(tostring(map))

    map:Add(1, "one")
    assert(1 == map:GetCount())
    print(tostring(map))
    map:Add(2, "two")
    assert(2 == map:GetCount())
    print(tostring(map))
    map:Add(3, "three")
    assert(3 == map:GetCount())
    print(tostring(map))

    assert("one" == map:Get(1))
    assert("two" == map:Get(2))
    assert("three" == map:Get(3))
    assert(3 == map:GetCount())
    assert(nil == map:Get(4))

    map:Set(1, "one_1")
    assert(3 == map:GetCount())
    assert("one_1" == map:Get(1))
    assert("two" == map:Get(2))
    assert("three" == map:Get(3))

    assert(true, "one_1" == map:Remove(1))
    assert(2 == map:GetCount())
    assert(nil == map:Get(1))
    assert("two" == map:Get(2))
    assert("three" == map:Get(3))

    assert(false == map:Remove(1))
    assert(2 == map:GetCount())
    assert(nil == map:Get(1))
    assert("two" == map:Get(2))
    assert("three" == map:Get(3))

    assert(true, "two" == map:Remove(2))
    assert(1 == map:GetCount())
    assert(nil == map:Get(1))
    assert(nil == map:Get(2))
    assert("three" == map:Get(3))

    assert(true, "three" == map:Remove(3))
    assert(0 == map:GetCount())
    assert(nil == map:Get(1))
    assert(nil == map:Get(2))
    assert(nil == map:Get(3))

    map:Add(1, "one")
    assert(1 == map:GetCount())
    map:Add(2, "two")
    assert(2 == map:GetCount())
    map:Add(3, "three")
    assert(3 == map:GetCount())

    map:Clear()
    assert(0 == map:GetCount())
    assert(nil == map:Get(1))
    assert(nil == map:Get(2))
    assert(nil == map:Get(3))

    map:Set(1, "one")
    assert(1 == map:GetCount())
    map:Set(2, "two")
    assert(2 == map:GetCount())
    map:Set(3, "three")
    assert(3 == map:GetCount())

    assert(map:ContainsKey(1))
    assert(map:ContainsKey(2))
    assert(map:ContainsKey(3))
    assert(not map:ContainsKey(4))

    map:Clear()
    assert(0 == map:GetCount())
    assert(nil == map:Get(1))
    assert(nil == map:Get(2))
    assert(nil == map:Get(3))

    map[1] = "one"
    assert(1 == map:GetCount())
    map[2] = "two"
    assert(2 == map:GetCount())
    map[3] = "three"
    assert(3 == map:GetCount())
end
Test1()


function Test2()

end